%module biosignal
%include "pyiterators.swg"

%fragment("SwigPyIterator_T");

%{
#include <sstream>

%}

%include "biosignal_common.i"


%define TO_STR()
	const char* __str__() {
    	std::stringstream ss;
    	ss << *$self;
    	const char * str = ss.str().c_str();
    	return str;
	};
%enddef

%define TO_ITERABLE()
   	swig::SwigPyIterator* __iter__(PyObject **PYTHON_SELF) {
       	return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
    }
%enddef


// defining traits for the given type needed for SwigPyIterator
%traits_swigtype(double);
%fragment(SWIG_Traits_frag(double));

%traits_swigtype(std::tr1::shared_ptr<biosignal::SignalData>);
%fragment(SWIG_Traits_frag(std::tr1::shared_ptr<biosignal::SignalData>));

%traits_swigtype(std::tr1::shared_ptr<biosignal::DataFrame>);
%fragment(SWIG_Traits_frag(std::tr1::shared_ptr<biosignal::DataFrame>));


%extend SignalData{
}

%extend DataFrame {
	TO_ITERABLE()
}

%extend SignalSlice {
	TO_ITERABLE()
}

%extend TimePeriod {
	TO_STR();
}

